import java.util.Random;

public class Text2 {
    public static void main(String[] args) {
        //定义数组表示奖池
        int[] arr = {2, 588, 888, 1000, 10000};
        //定义新数组存储抽奖结果
        int[] newArr = new int[arr.length];
        Random r = new Random();
        //5个奖项，循环五次
        for (int i = 0; i < 5; ) {
            //获取随机索引
            int randomIndex = r.nextInt(arr.length);
            //获取奖项
            int prize = arr[randomIndex];
            //判断当前的奖项是否存在，存在则重新抽取；不存在就表示是有效奖项
            boolean flag = contains(newArr, prize);
            if (!flag) {
                //把当前抽取的奖项添加到newArr中
                newArr[i] = prize;
                //添加完毕，移动索引
                i++;
            }
        }
        //遍历newArr
        for (int i = 0; i < newArr.length; i++) {
            System.out.println(newArr[i]);
        }
    }

    //定义方法判断prize在数组中是否存在
    //存在：true;不存在：false
    public static boolean contains(int[] arr, int prize) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == prize) {
                return true;
            }
        }
        return false;
    }
}
